package main

import "fmt"

func main() {
	fmt.Println(longestPalindrome("ccc"))
}

func longestPalindrome(s string) string {
	m := [][]bool{}
	n := len(s)
	for i := 0; i < n; i++ {
		m = append(m, make([]bool, n))
	}

	str := ""
	for i := 0; i < n; i++ {
		m[i][i] = true
		str = s[i : i+1]
	}

	for i := 0; i < n-1; i++ {
		if s[i] == s[i+1] {
			m[i][i+1] = true
			str = s[i : i+2]
		}
	}

	for l := 3; l <= n; l++ {
		for i := 0; i < n-l+1; i++ {
			if s[i] == s[i+l-1] && m[i+1][i+l-2] {
				m[i][i+l-1] = true
				str = s[i : i+l]
			}
		}
	}

	return str
}
